﻿using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;

namespace MoBaoPay.Model.Request
{
    /// <summary>
    /// 绑定银行卡参数
    /// </summary>
    internal class MoBaoBindCardRequest : IMoBaoRequest
    {
        private string requestUrl = "https://trade2.mobaopay.com/cashier/api/gateway.cgi";

        public string GetRequestUrl()
        {
            return requestUrl;
        }

        public void SetRequestUrl(string url)
        {
            requestUrl = url;
        }

        public IDictionary<string, string> GetRequestContent()
        {
            var dictionary = new Dictionary<string, string>()
            {
                { "apiName", ApiName },
                { "apiVersion", ApiVersion },
                { "custNo", CustNo },
                { "custname", CustName },
                { "phoneNo", PhoneNo },
                { "cardNo", CardNo },
                { "cardName", CardName },
                { "idCard", IdCard },
                { "signMsg", SignMsg }
            };
            return dictionary;
        }


        public void Sign(string path, string password)
        {
            var strData =
                $"apiName={ApiName}&apiVersion={ApiVersion}&cardName={CardName}&cardNo={CardNo}&custNo={CustNo}&custname={CustName}&idCard={IdCard}&phoneNo={PhoneNo}";
            this.SignMsg = MD5WithRSA.SignData(path, password, strData);
        }

        /// <summary>
        /// 接口名称
        /// </summary>
        public string ApiName { get; set; } = "FUND_BIND_CARD";

        /// <summary>
        /// 接口版本
        /// </summary>
        public string ApiVersion { get; set; } = "1.0.0.0";

        /// <summary>
        /// 商户号
        /// </summary>
        public string CustNo { get; set; } 

        /// <summary>
        /// 客户简称
        /// </summary>
        public string CustName { get; set; }

        /// <summary>
        /// 手机号
        /// </summary>
        public string PhoneNo { get; set; }

        /// <summary>
        /// 银行卡号
        /// </summary>
        public string CardNo { get; set; }

        /// <summary>
        /// 持卡人姓名
        /// </summary>
        public string CardName { get; set; }

        /// <summary>
        /// 身份证号
        /// </summary>
        public string IdCard { get; set; }

        /// <summary>
        /// 签名
        /// </summary>
        public string SignMsg { get; set; }


    }
}